﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Register.aspx.vb" Inherits="LecturerAppointmentSystem.Register" MasterPageFile="~/Outer.Master" %>

<asp:Content ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            height: 102px;
        }
    </style>
    <link href="Style.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <table class="style1">
        <tr>
            <td colspan="2">
                Please enter some information about yourself:
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="confirmation" runat="server" visible="false">
                
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                Fields marked with asterisks are mandatory
            </td>
        </tr>
        <asp:Panel ID="NamePanel" runat="server" Visible="false">
        <tr>
            <td align="right">
                First Name:
            </td>
            <td>
                <asp:TextBox ID="tb_firstname" runat="server" ValidationGroup="AllValidators"></asp:TextBox>
                <asp:RequiredFieldValidator ID="FirstNameRequiredFieldValidator" runat="server" 
                  ErrorMessage="Please enter your first name" ValidationGroup="AllValidators" 
                  Display="Dynamic" ControlToValidate="tb_firstname">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                Last Name:</td>
            <td width="70%">
                <asp:TextBox ID="tb_lastname" runat="server" ValidationGroup="AllValidators"></asp:TextBox>
                <asp:RequiredFieldValidator ID="LastNameRequiredFieldValidator" runat="server" 
                  ErrorMessage="Please enter your last name" ValidationGroup="AllValidators" 
                  Display="Dynamic" ControlToValidate="tb_lastname">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        </asp:Panel>
        <tr>
            <td align="right">
                Username:
                <br />
            </td>
            <td>
                <asp:TextBox ID="tb_username" runat="server" ValidationGroup="AllValidators"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tb_username"
                            ErrorMessage="UserName is required" ValidationGroup="AllValidators" Display="Dynamic">*</asp:RequiredFieldValidator>
                        &nbsp;<label id="UserAvailability" runat="server"></label>
                        <asp:CustomValidator ID="UsernameValidator" runat="server" ErrorMessage="Username already in use. Please choose another username."
                            ControlToValidate="tb_username" Display="Dynamic" ValidationGroup="AllValidators"></asp:CustomValidator>
                <br />
            </td>
        </tr>
        <asp:Panel ID="PasswordPanel" runat="server" Visible="false">
        <tr>
            <td align="right">
                Password:</td>
            <td>
                <asp:TextBox ID="tb_password" runat="server" TextMode="Password" ValidationGroup="AllValidators"></asp:TextBox>
                <asp:RequiredFieldValidator ID="PasswordRequiredFieldValidator" runat="server" 
                  ErrorMessage="Password is required" ValidationGroup="AllValidators" 
                  Display="Dynamic" ControlToValidate="tb_password">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                Confirm Password:</td>
            <td>
                <asp:TextBox ID="tb_confirmpassword" runat="server" TextMode="Password" ValidationGroup="AllValidators"></asp:TextBox>
                <asp:RequiredFieldValidator ID="ConfirmPasswordRequiredFieldValidator" runat="server" 
                  ErrorMessage="Please re-enter your password" ValidationGroup="AllValidators" 
                  Display="Dynamic" ControlToValidate="tb_confirmpassword">*</asp:RequiredFieldValidator>
                  <asp:CompareValidator ID="PasswordCompareValidator" runat="server" 
                  ValidationGroup="AllValidators" ErrorMessage="Passwords do not match" Display="Dynamic"
                  ControlToValidate="tb_confirmpassword" ControlToCompare="tb_password"></asp:CompareValidator>
            </td>
        </tr>
        </asp:Panel>
        <tr>
            <td align="right">
                University:</td>
            <td>
                <asp:DropDownList ID="ddl_University" runat="server" AutoPostBack="True" 
                    DataSourceID="ChooseUniversityDataSource" DataTextField="UniversityName" 
                    DataValueField="ID" ValidationGroup="AllValidators">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="UniversityRequired" runat="server" ControlToValidate="ddl_University"
                ErrorMessage="University is required" ValidationGroup="AllValidators" Display="Dynamic">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <asp:UpdatePanel ID="RoleUpdatePanel" runat="server">
                    <ContentTemplate>
        <tr>
            <td align="right">
                University Email:
            </td>
            <td>
                        <asp:TextBox ID="tb_uniEmail" runat="server" ValidationGroup="AllValidators"></asp:TextBox>
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="tb_uniEmail" ErrorMessage="Email is required."
                            ID="RequiredFieldValidator2" ValidationGroup="AllValidators" Display="Dynamic">*</asp:RequiredFieldValidator>
                        &nbsp;
                        <label id="EmailValidity" runat="server">
                        </label>
                        <asp:CustomValidator ID="EmailValidator" runat="server" ControlToValidate="tb_uniEmail"
                            Display="Dynamic" ValidationGroup="AllValidators"></asp:CustomValidator>
                <br />
            </td>
        </tr>
        <tr>
            <td class="style2" height="30px" valign="top" align="right">
                Are you a
            </td>
            <td class="style2">
                <asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID="ChooseRoleDataSource"
                    DataTextField="RoleName" DataValueField="RoleId" RepeatDirection="Horizontal"
                    AutoPostBack="True" OnTextChanged="Role_Changed" ValidationGroup="AllValidators">
                </asp:RadioButtonList>
                <asp:RequiredFieldValidator runat="server" ControlToValidate="RadioButtonList1" ErrorMessage="Please select one option"
                    ID="RequiredFieldValidator3" ValidationGroup="AllValidators">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="center">
            &nbsp
                            
                
            </td>
            <td>
                
                        &nbsp;<asp:MultiView ID="RoleMultiView" runat="server">
                            <asp:View ID="DefaultView" runat="server">
                            </asp:View>
                            <asp:View ID="StudentView" runat="server">

                                <asp:Label ID="lbl_studentNumber" runat="server" 
                                Text="Please enter your student number:"></asp:Label>
                                <br />
                                <asp:TextBox ID="tb_studentNumber" runat="server" ValidationGroup="AllValidators"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                    ControlToValidate="tb_studentNumber" Display="Dynamic" 
                                    ErrorMessage=" Please enter your student number" 
                                    ValidationGroup="AllValidators">*</asp:RequiredFieldValidator>
                                <br />
                                <asp:Label ID="lbl_course" runat="server" Text="Please choose your course:"></asp:Label>
                                <br />
                                <asp:DropDownList ID="ddl_chooseCourse" runat="server" DataSourceID="ChooseCourseDataSource"
                                    DataTextField="CourseName" DataValueField="ID" ValidationGroup="AllValidators">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="CourseValidator" runat="server" 
                                    ControlToValidate="ddl_chooseCourse" Display="Dynamic" 
                                    ErrorMessage=" Please choose your course" 
                                    ValidationGroup="AllValidators">*</asp:RequiredFieldValidator>
                            </asp:View>
                            <asp:View ID="LecturerView" runat="server">
                                <asp:Label ID="lbl_employeeNumber" runat="server" Text="Please enter your employee number:"></asp:Label>
                                <br />
                                <asp:TextBox ID="tb_employeeNumber" runat="server" ValidationGroup="AllValidators"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                    ControlToValidate="tb_employeeNumber" Display="Dynamic" 
                                    ErrorMessage="Please enter your employee number" 
                                    ValidationGroup="AllValidators">*</asp:RequiredFieldValidator>
                                <br />
                                <br />
                                <asp:Label ID="lbl_faculty" runat="server" Text="Please choose your faculty:"></asp:Label>
                                <br />
                                <asp:DropDownList ID="ddl_chooseFaculty" runat="server" DataSourceID="FacultyDataSource"
                                    DataTextField="FacultyName" DataValueField="FacultyName" ValidationGroup="AllValidators">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="FacultyValidator" runat="server" 
                                    ControlToValidate="ddl_chooseFaculty" Display="Dynamic" 
                                    ErrorMessage=" Please choose your faculty" 
                                    ValidationGroup="AllValidators">*</asp:RequiredFieldValidator>
                            </asp:View>
                        </asp:MultiView>
                        <br />
                    <br />&nbsp;</td>
        </tr>
        </ContentTemplate>
                </asp:UpdatePanel>
        <tr>
            <td align="right">
                Contact Number:
            </td>
            <td>
                <asp:TextBox ID="tb_contact" runat="server"></asp:TextBox>
            </td>
        </tr>
         <tr>
            <td width="30%">
                &nbsp;
            </td>
            <td>
                        <asp:Button ValidationGroup="AllValidators" ID="btn_submit" runat="server" Text="Submit" CausesValidation="true" />
                        <br />
                        <br />
                        <asp:Label ID="lbl_MailError" runat="server" Visible="False"></asp:Label>
                        <br />
                <asp:SqlDataSource ID="ChooseUniversityDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>" 
                    ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>" 
                    SelectCommand="SELECT * FROM [Universities]"></asp:SqlDataSource>
                        <br />
                <asp:SqlDataSource ID="ChooseRoleDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>"
                    SelectCommand="SELECT TOP 2 RoleId, RoleName FROM aspnet_Roles ORDER BY RoleId DESC">
                </asp:SqlDataSource>
                        <br />
                                <asp:SqlDataSource ID="ChooseCourseDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>"
                                    ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>"
                                    
                            SelectCommand="SELECT * FROM [Courses] WHERE ([UniversityName] = ?)">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="ddl_University" Name="UniversityName" 
                                            PropertyName="SelectedValue" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                            <br />
                                <asp:SqlDataSource ID="FacultyDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>"
                                    ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>"
                                    
                            SelectCommand="SELECT * FROM [Faculties] WHERE ([UniversityName] = ?)">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="ddl_University" Name="UniversityName" 
                                            PropertyName="SelectedValue" Type="Int32" />
                                    </SelectParameters>
                        </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
